Skip to content

feat(resync): Add support to update snapshot config (max_parallel_workers, num_tables, rows_per_partition) during resync signal#4276

Merged
masterashu merged 13 commits into
mainfrom
dbi-546
May 29, 2026
Merged

feat(resync): Add support to update snapshot config (max_parallel_workers, num_tables, rows_per_partition) during resync signal#4276
masterashu merged 13 commits into
mainfrom
dbi-546

Conversation

@masterashu

@masterashu masterashu commented May 6, 2026

Copy link
Copy Markdown
Contributor

Tested scenarios:

Initial + CDC Pipes:

  • Running pipe -> Resync (working)
  • Paused Pipe -> Resync (working)
  • Snapshot -> Resync (working)

Initial only Pipes:

  • Completed -> Resync (working)
  • Failed -> Resync (working)
  • Snapshot -> Resync (working)

CDC Only Pipes:

  • Running -> Resync (working) [Does snapshot]
  • Paused -> Resync (working) [Does snapshot]

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🔄 Flaky Test Detected

Analysis: The failure is a transient Docker container initialization error for the mysql-gtid 6.0 lts matrix variant — no tests ran at all, all test steps were skipped, while all sibling matrix jobs passed in the same run.
Confidence: 0.92

✅ Automatically retrying the workflow

View workflow run

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2278 2 2276 203
View the top 2 failed test(s) by shortest run time
github.com/PeerDB-io/peerdb/flow/e2e::TestApiPg
Stack Traces | 0.01s run time
=== RUN   TestApiPg
=== PAUSE TestApiPg
=== CONT  TestApiPg
--- FAIL: TestApiPg (0.01s)
2026/05/29 09:19:45 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/05/29 09:19:45 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
github.com/PeerDB-io/peerdb/flow/e2e::TestApiPg/TestPostgresTableOIDsMigration
Stack Traces | 0.14s run time
=== RUN   TestApiPg/TestPostgresTableOIDsMigration
=== PAUSE TestApiPg/TestPostgresTableOIDsMigration
=== CONT  TestApiPg/TestPostgresTableOIDsMigration
2026/05/29 09:18:46 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/05/29 09:18:46 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    api_test.go:2716: 
        	Error Trace:	.../flow/e2e/api_test.go:2716
        	Error:      	Received unexpected error:
        	            	failed to get workflow_id for flow test_postgres_table_oids_api_weodcxsd: FATAL: terminating connection due to administrator command (SQLSTATE 57P01)
        	Test:       	TestApiPg/TestPostgresTableOIDsMigration
    api_test.go:49: begin tearing down postgres schema api_weodcxsd
--- FAIL: TestApiPg/TestPostgresTableOIDsMigration (0.14s)
View the full list of 2 ❄️ flaky test(s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuitePG

Flake rate in main: 17.25% (Passed 355 times, Failed 74 times)

Stack Traces | 0.01s run time
=== RUN   TestPeerFlowE2ETestSuitePG
=== PAUSE TestPeerFlowE2ETestSuitePG
=== CONT  TestPeerFlowE2ETestSuitePG
--- FAIL: TestPeerFlowE2ETestSuitePG (0.01s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuitePG/Test_NaN_Infinity_PG

Flake rate in main: 18.18% (Passed 18 times, Failed 4 times)

Stack Traces | 31.1s run time
=== RUN   TestPeerFlowE2ETestSuitePG/Test_NaN_Infinity_PG
=== PAUSE TestPeerFlowE2ETestSuitePG/Test_NaN_Infinity_PG
=== CONT  TestPeerFlowE2ETestSuitePG/Test_NaN_Infinity_PG
    postgres_test.go:315: UNEXPECTED STATUS TIMEOUT STATUS_SNAPSHOT
    postgres.go:92: begin tearing down postgres schema pg_wfrqiefx
--- FAIL: TestPeerFlowE2ETestSuitePG/Test_NaN_Infinity_PG (31.14s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Flaky Test Detected

Analysis: TestPostgresSSHKeepaliveLatency panicked with "watch already in progress" — a race condition in pgx's context watcher during SSH keepalive connection close — crashing the entire connectors/postgres test binary and marking all sibling tests as failed with unknown status.
Confidence: 0.82

✅ Automatically retrying the workflow

View workflow run

@masterashu masterashu marked this pull request as ready for review May 12, 2026 13:38
@masterashu masterashu requested a review from a team as a code owner May 12, 2026 13:38
@masterashu masterashu requested review from jgao54 and pfcoperez May 12, 2026 13:38
@claude

claude Bot commented May 12, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

This comment was marked as resolved.

@github-actions

This comment was marked as resolved.

changes = append(changes, fmt.Sprintf("tables removed: %v", removedTables))
}

if update.SnapshotMaxParallelWorkers > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this to activity logging as well!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for same of completion, let's include batchSize, idleTimeout, snapshotNumPartitionsOverride to match LogActivityUpdateFlowConfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Only logging fields that don't need old values to compare to

The caller here will actually pass all values, changed and unchanged, and the flow-api can't distinguish which ones to log. Logging the list of tables has to happen here because they're not applied to the config until snapshotting is done, so keeping just tables and leaving the rest to the worker is better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

Comment thread flow/cmd/handler.go Outdated
Comment thread flow/cmd/handler.go Outdated
Comment thread flow/workflows/cdc_flow.go Outdated
Comment thread flow/workflows/cdc_flow.go Outdated
Comment thread flow/cmd/handler.go Outdated
Comment on lines +507 to +508
// Override Snapshot Parameters
overrideSnapshotParametersInResync(req, config)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i may regret saying this (lol) but for now we are not validating these snapshot parameters so we could just remove it altogether.

maybe can add a comment here mentioning that. this avoids having update these config fields.

@jgao54

jgao54 commented May 14, 2026

Copy link
Copy Markdown
Contributor

missing e2e test for this to ensure that resync propagates snapshot config changes

@github-actions

This comment was marked as outdated.

Comment thread flow/workflows/cdc_flow.go

@pfcoperez pfcoperez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM except for the seemingly unused method. I also wonder if we can unit test the config extraction, basically checking the right fields are extracted from a test.

Comment thread flow/cmd/handler.go Outdated

@jgao54 jgao54 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm as well once @pfcoperez 's comment is addressed :) !

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: The newly-added TestResyncWithSnapshotConfigOverride fails deterministically across all 9 matrix combinations (3 DB versions x 3 API sub-suites) with the same logical error "unable to signal workflow update: workflow execution already completed" — indicating a real bug in the new resync-signal feature on this PR, not transient flakiness.
Confidence: 0.92

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: TestResyncWithSnapshotConfigOnResyningPipe fails identically across MySQL/Postgres/Mongo with "UNEXPECTED TIMEOUT wait for mirror to be in cdc" — this directly tests the feature added by the PR (resync snapshot config override), indicating a real bug in the resync→cdc transition, not flakiness.
Confidence: 0.9

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: TestApiMy/TestResyncWithSnapshotConfigDuringSnapshot fails deterministically across all three MySQL/MariaDB matrix jobs with the same SQL syntax error near '(1,2000) g' (PostgreSQL generate_series syntax executed against MySQL), indicating a real code bug rather than flakiness.
Confidence: 0.95

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@claude

claude Bot commented May 28, 2026

Copy link
Copy Markdown

Code review

Found 1 issue. Checked for bugs and CLAUDE.md compliance.
Bug: resync-during-resync path writes _resync-suffixed table mappings to catalog
File: flow/workflows/cdc_flow.go, line 666
The comment on line 662 says we need to NOT sync the tableMappings to catalog to preserve original names. The old code intentionally used uploadConfigToCatalog(ctx, cfg) which uploaded cfg directly - at this point cfg.TableMappings has been restored to originalTableMappings (un-suffixed) on line 660.
The new code calls syncStateToConfigProtoInCatalog(ctx, cfg, state), which internally calls updateFlowConfigWithLatestSettings (lines 44-65). At line 51, it overwrites the clone TableMappings with state.SyncFlowOptions.TableMappings - which still has the _resync suffixes applied at lines 628-631. This means: (1) The catalog will be written with _resync-suffixed table names, contradicting the intent. (2) The resyncCfg passed into DropFlowInput.FlowConnectionConfigs will also carry suffixed names - when the flow is recreated, lines 628-631 will append another _resync, resulting in double-suffixed destinations like tablename_resync_resync.
Suggested fix: Apply the snapshot overrides directly to cfg (similar to applySnapshotConfigOverrides in handler.go) and keep using uploadConfigToCatalog(ctx, cfg) for this specific path, since it must NOT pull table mappings from state.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Flaky Test Detected

Analysis: TestGenericCH_PG/Test_Initial_Custom_Partition failed because the catalog Postgres connection was terminated mid-test with SQLSTATE 57P01 (admin_shutdown), a transient infrastructure issue rather than a code bug.
Confidence: 0.92

✅ Automatically retrying the workflow

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Flaky Test Detected

Analysis: Catalog Postgres connection terminated mid-test with SQLSTATE 57P01 (admin_shutdown) — a transient infrastructure error unrelated to the test's logic, failing only 1 of 2448 tests in a single shard.
Confidence: 0.9

✅ Automatically retrying the workflow

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Flaky Test Detected

Analysis: TestApiMy/TestResyncWithSnapshotConfigOnRunningPipe hit an "UNEXPECTED TIMEOUT wait for flow dropped" (60s) on the mysql-gtid/6.0 matrix variant only, while the maria/8.0 and mysql-pos/7.0 jobs passed — timing/async-completion flakiness rather than a logic bug.
Confidence: 0.8

✅ Automatically retrying the workflow

View workflow run

changes = append(changes, fmt.Sprintf("tables removed: %v", removedTables))
}

if update.SnapshotMaxParallelWorkers > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Only logging fields that don't need old values to compare to

The caller here will actually pass all values, changed and unchanged, and the flow-api can't distinguish which ones to log. Logging the list of tables has to happen here because they're not applied to the config until snapshotting is done, so keeping just tables and leaving the rest to the worker is better.

Comment thread flow/workflows/cdc_flow.go Outdated

// We still override the snapshot parameters (when resync with updated values)
overrideSnapshotParametersInState(val, state)
resyncCfg := syncStateToConfigProtoInCatalog(ctx, cfg, state)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments just above mention needing to not sync the tableMappings to catalog because they have _resync at the end, and syncStateToConfigProtoInCatalog does exactly that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid without code duplication, can move applySnapshotConfigOverrides to internal, change it to ConfigsCore, and inline the h.ValidateCDCMirror call to be able to pass ConfigsCore earlier. Then this one can be

internal.ApplySnapshotConfigOverrides(cfg, val.GetFlowConfigUpdate().GetCdcFlowConfigUpdate())
uploadConfigToCatalog(ctx, cfg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole signal + mutable state thing is a mess so I understand that it's very confusing to deal with

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Flaky Test Detected

Analysis: TestApiPg/TestPostgresTableOIDsMigration failed with PostgreSQL SQLSTATE 57P01 (terminating connection due to administrator command) — an infrastructure-level connection kill rather than a test logic failure, consistent with flaky CI behavior.
Confidence: 0.85

✅ Automatically retrying the workflow

View workflow run

@masterashu masterashu merged commit fafb90f into main May 29, 2026
16 of 18 checks passed
@masterashu masterashu deleted the dbi-546 branch May 29, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants